package edu.mit.media.fv.aqview
{
	import edu.mit.media.fv.blocks.*;
	import edu.mit.media.fv.components.*;
	import edu.mit.media.fv.events.*;
	import edu.mit.media.fv.fluidspace.*;
	import edu.mit.media.fv.aqwidgets.*;
	
	import flash.display.*;
	import flash.events.MouseEvent;
	import flash.text.*;
	
	public class AQTextBuilder extends AQViewer
	{
		
		var _text:AQTextArea;
		var _tags:AQTextField;
		var _sendButton:DisplayObject;
		
		public function AQTextBuilder()
		{
			super();
			FluidEventHandler.addEventListener(WidgetEvent.DISPLAY_TEXT_BUILDER, displayWidget);
		}
		public function displayWidget(event:WidgetEvent = null):void{
			FluidEventHandler.dispatchEvent(new WidgetEvent(WidgetEvent.DISPLAY_WIDGET, this, "Text"));

			if(event.id == -1){
				this._tags.text = "";
				this._text.text = "";
				this.id = event.id;
			}else{
				this._tags.text = "RE: "+event.subject;
				this._text.text = "";
				this.id = event.id;
			}
			
		}
		private function sendMessage(event:MouseEvent):void{
			var data:Object = new Object();
			data.command = FluidConstants.REQUEST_SEND_OBJECT;
			data.type = FluidConstants.TEXT;
			data.tags = this._tags.text;
			data.priority = 1;
			data.text = this._text.text;
			data.id = this.id;
			data.reply = this.id;
			var fvne:FVNetworkEvent = new FVNetworkEvent(data);
			FluidEventHandler.dispatchEvent(fvne);
			
			FluidEventHandler.dispatchEvent(new WidgetEvent(WidgetEvent.DISPLAY_WORKSPACE));
		}

	}
}